package game.metalmax.ui
{
	import flash.display.DisplayObjectContainer;
	
	import game.metalmax.controller.Notifications;
	import game.metalmax.ui.login.LoginWindow;
	
	import showtime.framework.manager.WindowManager;
	import showtime.framework.mvc.interfaces.INotification;
	import showtime.framework.mvc.patterns.mediator.Mediator;

	public class UILayerMediator extends Mediator
	{		
		private var parent:Object = null;
		
		public function UILayerMediator(parent:Object)
		{
			super(String(UILayerMediator));
			
			this.parent = parent;
		}
		
		override public function onRegister():void
		{
			super.onRegister();
			
			viewComponent = new UILayer();
			parent.addChild(viewComponent);	
		}
		
		override public function onRemove():void
		{
			super.onRemove();
		}
		
		override public function listNotificationInterests():Array
		{
			return [Notifications.LOIN_GAME];
		}
		
		override public function handleNotification(notification:INotification):void
		{
			switch (notification.getName())
			{
				case Notifications.LOIN_GAME:
				{
					loginGame(notification.getBody());
					break;
				}
				
			}
			
			
		}
		
		////////////////////////////////////////////////////////
		//			  Login methods.						///
		///////////////////////////////////////////////////////
		
		private function loginGame(data:Object):void
		{
			WindowManager.createPopUp(LoginWindow, DisplayObjectContainer(viewComponent));
		}
		
	
	}
}